#encoding = utf-8

import pytest
import requests
import json
from shargeApi.login import LoginAPI
import allure
from shargeApi.config import *

@allure.epic("sharge")
@allure.feature("logintest")
class Testusrmode:



    def setup(self):
        pass

    def teardown(self):
        pass

    @allure.title("密码登陆账号")
    def test01_login(self):
        url = url_login_password
        json_data = {"area":"86","mobile":"15361441154","password":"147952la"}
        jsondata= json.dumps(json_data)
        headers = {"Content-Type":"application/json"}
        res = requests.post(url = url,data = jsondata.encode('utf-8'),  headers=headers)

        result = json.loads(res.text)
        print(result)
        print(res.request.url)
        assert result["message"] =="成功"
        # return result["data"]["sessionId"]

    @allure.title("验证码登陆账号")
    def test02_login(self):
        url = url_login_code
        json_data = {"code":"123456","area":"86","mobile":"19811977036"}
        jsondata= json.dumps(json_data)
        headers = {"Content-Type":"application/json"
                   }
        res = requests.post(url = url,data = jsondata.encode('utf-8'),  headers=headers)

        result = json.loads(res.text)
        print(result)
        # assert result["message"] == "成功"


